home *** CD-ROM | disk | FTP | other *** search
/ Super PC 35 / Super PC 35 (Shareware).iso / spc / SONIDO / IT106 / ITTECH.DOC < prev    next >
Encoding:
Text File  |  1996-03-09  |  18.0 KB  |  381 lines

  1.  
  2.                              Impulse Header Layout
  3.  
  4.         0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  5.       ┌───┬───┬───┬───┬───────────────────────────────────────────────┐
  6. 0000: │'I'│'M'│'P'│'M'│ Song Name, max 26 characters, includes NULL   │
  7.       ├───┴───┴───┴───┴───────────────────────────────────────┬───┬───┤
  8. 0010: │.......................................................│ x │ x │
  9.       ├───────┬───────┬───────┬───────┬───────┬───────┬───────┼───┴───┤
  10. 0020: │OrdNum │InsNum │SmpNum │PatNum │ Cwt/v │ Cmwt  │ Flags │Special│
  11.       ├───┬───┼───┬───┼───┬───┼───────┼───────┴───────┼───┬───┼───┬───┤
  12. 0030: │GV │MV │IS │IT │Sep│(0)│MsgLgth│Message Offset │ x │ x │ x │ x │
  13.       ├───┴───┴───┴───┴───┴───┴───────┴───────────────┴───┴───┴───┴───┤
  14. 0040: │ Chnl Pan (64 bytes)...........................................│
  15.       ├───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┤
  16.  
  17.       ├───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┤
  18. 0080: │ Chnl Vol (64 bytes)...........................................│
  19.       ├───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┤
  20.  
  21.       ├───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┤
  22. 00C0: │ Orders, Length = OrdNum                                       │
  23.       ├───────────────────────────────────────────────────────────────┤
  24. xxxx: │ 'Long' Offset of instruments, Length = InsNum*4 (1)           │
  25.       ├───────────────────────────────────────────────────────────────┤
  26. xxxx: │ 'Long' Offset of samples headers, Length = SmpNum*4 (2)       │
  27.       ├───────────────────────────────────────────────────────────────┤
  28. xxxx: │ 'Long' Offset of patterns, Length = PatNum*4 (3)              │
  29.       └───────────────────────────────────────────────────────────────┘
  30.  
  31.       (1) Offset = 00C0h+OrdNum
  32.       (2) Offset = 00C0h+OrdNum+InsNum*4
  33.       (3) Offset = 00C0h+OrdNum+InsNum*4+SmpNum*4
  34.  
  35.         Note that if the (long) offset to a pattern = 0, then the
  36.         pattern is assumed to be a 64 row empty pattern.
  37.  
  38.       Cwt:      Created with tracker.
  39.                  Impulse Tracker y.xx = 0yxxh
  40.       Cmwt:     Compatible with tracker with version greater than value.
  41.       OrdNum:   Number of orders in song.
  42.       InsNum:   Number of instruments in song
  43.       SmpNum:   Number of samples in song
  44.       PatNum:   Number of patterns in song
  45.       Flags:    Bit 0: On = Stereo, Off = Mono
  46.                 Bit 1: Vol0MixOptimizations - If on, no mixing occurs if
  47.                        the volume at mixing time is 0 (redundant v1.04+)
  48.                 Bit 2: On = Use instruments, Off = Use samples.
  49.                 Bit 3: On = Linear slides, Off = Amiga slides.
  50.                 Bit 4: On = Old Effects, Off = IT Effects
  51.                         Differences:
  52.                        - Vibrato is updated EVERY frame in IT mode, whereas
  53.                           it is updated every non-row frame in other formats.
  54.                           Also, it is two times deeper with Old Effects ON
  55.                        - Command Oxx will set the sample offset to the END
  56.                          of a sample instead of ignoring the command under
  57.                          old effects mode.
  58.                        - (More to come, probably)
  59.  
  60.       Special:  Bit 0: On = song message attached.
  61.                        Song message:
  62.                         Stored at offset given by "Message Offset" field.
  63.                         Length = MsgLgth.
  64.                         NewLine = 0Dh (13 dec)
  65.                         EndOfMsg = 0
  66.  
  67.                        Note: v1.04+ of IT may have song messages of up to
  68.                              8kb included.
  69.  
  70.                 Bits 1-15: Undefined.
  71.  
  72.       GV:       Global volume. (0->128) All volumes are adjusted by this
  73.       MV:       Mix volume (0->128) During mixing, this value controls
  74.                 the magnitude of the wave being mixed.
  75.       IS:       Initial Speed of song.
  76.       IT:       Initial Tempo of song
  77.       Sep:      Panning separation between channels (0->128, 128 is max sep.)
  78.       Chnl Vol: Volume for each channel. Ranges from 0->64
  79.       Chnl Pan: Each byte contains a panning value for a channel. Ranges from
  80.                  0 (absolute left) to 64 (absolute right). 32 = central pan,
  81.                  100 = Surround sound.
  82.                  +128 = disabled channel (notes will not be played, but note
  83.                                           that effects in muted channels are
  84.                                           still processed)
  85.       Orders:   This is the order in which the patterns are played.
  86.                  Valid values are from 0->199.
  87.                  255 = "---", End of song marker
  88.                  254 = "+++", Skip to next order
  89.  
  90.  
  91.                            Impulse Instrument Format
  92.  
  93.         0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  94.       ┌───┬───┬───┬───┬───────────────────────────────────────────────┐
  95. 0000: │'I'│'M'│'P'│'I'│ DOS FileName (12345678.123)                   │
  96.       ├───┼───┼───┼───┼───┬───┬───┬───┬───────┬───┬───┬───────┬───┬───┤
  97. 0010: │00h│Flg│VLS│VLE│SLS│SLE│ x │ x │FadeOut│NNA│DNC│TrkVers│NoS│ x │
  98.       ├───┴───┴───┴───┴───┴───┴───┴───┴───────┴───┴───┴───────┴───┴───┤
  99. 0020: │ Instrument Name, max 26 bytes, includes NUL...................│
  100.       ├───────────────────────────────────────┬───┬───┬───┬───┬───┬───┤
  101. 0030: │.......................................│ x │ x │ x │ x │ x │ x │
  102.       ├───────────────────────────────────────┴───┴───┴───┴───┴───┴───┤
  103. 0040: │ Note-Sample/Keyboard Table, Length = 240 bytes................│
  104.       ├───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┤
  105.  
  106.       ├───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┤
  107. 0130: │ Volume envelope (200 bytes)...................................│
  108.       ├───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┤
  109.  
  110.                                       ├───┴───┴───┴───┴───┴───┴───┴───┤
  111. 01F8:                                 │ Node points (25x2 bytes)......│
  112.                                       └───────────────────────────────┘
  113.  
  114.         Total length of an instrument header is 554 bytes. But for practical
  115.         use in a player, it's better to load 504 bytes (up to 1F8h) into
  116.         memory, load the extra 50 bytes into a temporary buffer and look up the
  117.         node times (for VLS/VLE/SLS/SLE) during loadup (as opposed to during
  118.         playback).
  119.  
  120.       Flg:      Bit 0. On = Use volume envelope
  121.                 Bit 1. On = Use volume loop
  122.                 Bit 2. On = Use sustain volume loop
  123.       VLS:      Volume loop start (node number)
  124.       VLE:      Volume loop end (node number)
  125.       SLS:      Sustain loop start (node number)
  126.       SLE:      Sustain loop end (node number)
  127.       FadeOut:  Ranges between 0 and 64, but the fadeout "Count" is 512.
  128.                 See the Last section on how this works.
  129.                 Fade applied when:
  130.                 1) Note fade NNA is selected and triggered (by another note)
  131.                 2) Note off NNA is selected with no volume envelope
  132.                    or volume envelope loop
  133.                 3) Volume envelope end is reached
  134.  
  135.       DNC:      Duplicate note check (0 = Off, 1 = On)
  136.       NNA:      New note action:
  137.                         0 = Note cut
  138.                         1 = Note off
  139.                         2 = Note continue
  140.                         3 = Note fade
  141.  
  142.       TrkVers:  Tracker version used to save the instrument. This is only
  143.                 used in the instrument files.
  144.       NoS:      Number of samples associated with instrument. This is only
  145.                 used in the instrument files.
  146.  
  147.       Note-Sample/Keyboard Table.
  148.        Each note of the instrument is first converted to a sample number
  149.        and a note (C-0 -> B-9). These are stored as note/sample pairs
  150.        (note first, range 0->119 for C-0 to B-9, sample ranges from
  151.        1-99, 0=no sample)
  152.  
  153.        Volume envelope: Values from 0->64, 0FFh indicating end of envelope.
  154.        (after which note fade applies)
  155.  
  156.       Node data: Tick THEN magnitude
  157.  
  158.  
  159.  
  160.                              Impulse Sample Format
  161.  
  162.         0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  163.       ┌───┬───┬───┬───┬───────────────────────────────────────────────┐
  164. 0000: │'I'│'M'│'P'│'S'│ DOS Filename (12345678.123)                   │
  165.       ├───┼───┼───┼───┼───────────────────────────────────────────────┤
  166. 0010: │00h│GvL│Flg│Vol│ Sample Name, max 26 bytes, includes NUL.......│
  167.       ├───┴───┴───┴───┴───────────────────────────────────────┬───┬───┤
  168. 0020: │.......................................................│ x │ x │
  169.       ├───────────────┬───────────────┬───────────────┬───────┴───┴───┤
  170. 0030: │ Length        │ Loop Begin    │ Loop End      │ C5Speed       │
  171.       ├───────────────┼───────────────┼───────────────┼───┬───┬───┬───┤
  172. 0040: │ SusLoop Begin │ SusLoop End   │ SamplePointer │ViS│ViD│ViR│ViT│
  173.       └───────────────┴───────────────┴───────────────┴───┴───┴───┴───┘
  174.  
  175. The cache file has the following pieces of information added on:
  176.  
  177.         0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  178.       ┌───────────────┬───────┬───────┬───┬───────────────────────────┐
  179. 0050: │ File Size     │ Date  │ Time  │Fmt│...........................│
  180.       └───────────────┴───────┴───────┴───┴───────────────────────────┘
  181.  
  182.         Fmt. 0 = unchecked. 1 = directory, 2 = it sample, 3 = st sample
  183.  
  184.  
  185.       GvL:      Global volume for instrument, ranges from 0->64
  186.       Flg:      Bit 0. On = sample associated with header.
  187.                 Bit 1. On = 16 bit, Off = 8 bit.
  188.                 Bit 2. On = stereo, Off = mono. Stereo samples not supported yet
  189.                 Bit 3. Reserved
  190.                 Bit 4. On = Use loop
  191.                 Bit 5. On = Use sustain loop
  192.                 Bit 6. On = Ping Pong loop, Off = Forwards loop
  193.                 Bit 7. On = Ping Pong Sustain loop, Off = Forwards Sustain loop
  194.       Vol:      Default volume for instrument
  195.  
  196.       Length:   Length of sample in no. of samples NOT no. of bytes
  197.       LoopBeg:  Start of loop (no of samples in, not bytes)
  198.       Loop End: Sample no. AFTER end of loop
  199.       C5Speed:  Number of bytes a second for C-5 (ranges from 0->9999999)
  200.       SusLBeg:  Start of sustain loop
  201.       SusLEnd:  Sample no. AFTER end of sustain loop
  202.  
  203.       SmpPoint: 'Long' Offset of sample in file.
  204.  
  205.       ViS:      Vibrato Speed, ranges from 0->64
  206.       ViD:      Vibrato Depth, ranges from 0->64
  207.       ViT:      Vibrato waveform type.
  208.                         0=Sine wave
  209.                         1=Ramp down
  210.                         2=Square wave
  211.                         3=Random (speed is irrelevant)
  212.       ViR:      Vibrato Rate, rate at which vibrato is applied (0->64)
  213.  
  214.         The depth of the vibrato at any point is worked out in the following
  215.         way:
  216.           Every processing cycle, the following occurs:
  217.                 1) Mov AX, [SomeVariableNameRelatingToVibrato]
  218.                 2) Add AL, Rate
  219.                 3) AdC AH, 0
  220.                 4) AH contains the depth of the vibrato as a fine-linear slide.
  221.                 5) Mov [SomeVariableNameRelatingToVibrato], AX  ; For the next
  222.                                                                 ; cycle.
  223.  
  224.         For those that don't understand assembly, then the depth is
  225.         basically the running-sum of the rate divided by 256.
  226.  
  227.         Sample vibrato uses a table 256-bytes long
  228.  
  229.    Note: The sample load routine uses bytes the at 2Eh and 2Fh for conversion
  230.          flags! So DON'T write anything there!
  231.  
  232.          All samples are UNSIGNED (even 16-bit ones)
  233.  
  234.  
  235.  
  236.                              Impulse Pattern Format
  237.  
  238.         0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  239.       ┌───────┬───────┬───┬───┬───┬───┬───────────────────────────────┐
  240. 0000: │Length │ Rows  │ x │ x │ x │ x │ Packed data................   │
  241.       ├───┬───┼───┬───┼───┼───┼───┼───┼───┬───┬───┬───┬───┬───┬───┬───┤
  242.  
  243.       Length:   Length of packed pattern, not including the 8 byte header
  244.                 Note that the pattern + the 8 byte header will ALWAYS
  245.                 be less than 64k
  246.       Rows:     Number of rows in this pattern (Ranges from 32->200)
  247.  
  248.       Patterns are unpacked by the following pseudocode... (this may look
  249.       horrible, but in practise, it's just as conveninent as the S3M
  250.       pattern format for playback (but not for display))
  251.  
  252.       GetNextChannelMarker:
  253.         Read byte into channelvariable.
  254.         if(channelvariable = 0) then end of row
  255.         Channel = (channelvariable-1) & 63              ; Channel is 0 based.
  256.         if(channelvariable & 128) then read byte into maskvariable
  257.           else maskvariable = previousmaskvariable for current channel
  258.  
  259.         if(maskvariable & 1), then read note. (byte value)
  260.                 // Note ranges from 0->119 (C-0 -> B-9)
  261.                 // 255 = note off, 254 = notecut
  262.  
  263.         if(maskvariable & 2), then read instrument (byte value)
  264.                 // Instrument ranges from 1->99
  265.  
  266.         if(maskvariable & 4), then read volume/panning (byte value)
  267.                 // Volume ranges from 0->64
  268.                 // Panning ranges from 0->64, mapped onto 128->192
  269.  
  270.         if(maskvariable & 8), then read command (byte value) and commandvalue
  271.                 // Valid ranges from 0->31 (0=no effect, 1=A, 2=B, 3=C, etc.)
  272.  
  273.         if(maskvariable & 16), then note = lastnote for channel
  274.         if(maskvariable & 32), then instrument = lastinstrument for channel
  275.         if(maskvariable & 64), then volume/pan = lastvolume/pan for channel
  276.         if(maskvariable & 128), then {
  277.                 command = lastcommand for channel and
  278.                 commandvalue = lastcommandvalue for channel
  279.         }
  280.         Goto GetNextChannelMarker
  281.  
  282.  
  283.  
  284.                                   Mathematics
  285.  
  286. Abbreviations:
  287.  FV = Final Volume (Ranges from 0 to 128). In versions 1.04+, mixed output
  288.       devices are reduced further to a range from 0 to 64 due to lack of
  289.       memory.
  290.  Vol = Volume at which note is to be played. (Ranges from 0 to 64)
  291.  SV = Sample Volume (Ranges from 0 to 64)
  292.  CV = Channel Volume (Ranges from 0 to 64)
  293.  GV = Global Volume (Ranges from 0 to 128)
  294.  VEV = Volume Envelope Value (Ranges from 0 to 64)
  295.  
  296. In Sample mode, the following calculation is done:
  297.  FV = Vol * SV * CV * GV / 262144               ; Note that 262144 = 2^18
  298.                                                 ; So bit shifting can be done.
  299.  
  300. In Instrument mode the following procedure is used:
  301.  
  302.  1) Update volume envelope value. Check for loops / end of envelope.
  303.  2) If end of volume envelope (ie. position >= 200 or VEV = 0FFh), then turn
  304.         on note fade.
  305.  3) If notefade is on, then NoteFadeComponent (NFC) = NFC - FadeOut
  306.         ; NFC should be initialised to 512 when a note is played.
  307.  4) FV = Vol * SV * CV * GV * VEV * NFC / 8589934592
  308.                                                 ; Note that 8589934592 = 2^33
  309.  
  310. Linear slides work like this:
  311.  Final frequency = Original frequency * 2^(SlideValue/768)
  312.  
  313. (I used a lookup table for the multipliers here)
  314.  
  315. For command Exx, SlideValue = -4*EffectValue
  316. For command EEx, SlideValue = -EffectValue
  317. For command Fxx, SlideValue = 4*EffectValue
  318. For command FEx, SlideValue = EffectValue
  319.  
  320. Note that sample vibrato always uses Linear slides.
  321.  
  322. Notes about effects (as compared to other module formats)
  323.  
  324. C               This is now in *HEX*. (Used to be in decimal in ST3)
  325. E/F/G/H/U       You need to check whether the song uses Amiga/Linear slides.
  326. H/U             Vibrato in Impulse Tracker is two times finer than in
  327.                 any other tracker and is updated EVERY tick.
  328.                 If "Old Effects" is *ON*, then the vibrato is played in the
  329.                 normal manner (every non-row tick and normal depth)
  330. E/F/G           These commands ALL share the same memory.
  331. Oxx             Offsets to samples are to the 'xx00th' SAMPLE. (ie. for
  332.                 16 bit samples, the offset is xx00h*2)
  333.                 Oxx past the sample end will be ignored, unless "Old Effects"
  334.                 is ON, in which case the Oxx will play from the end of the
  335.                 sample.
  336. Yxy             This uses a table 4 times larger (hence 4 times slower) than
  337.                 vibrato or tremelo. If the waveform is set to random, then
  338.                 the 'speed' part of the command is interpreted as a delay.
  339.  
  340. If you read through this document and there are ANY points which you have
  341. troubles with (and have to try out), then let me know - because someone
  342. else will have the same questions - and I'd like to make this DOC as easy
  343. to understand as possible.
  344.  
  345.                                   General Info
  346.  
  347. The player in Impulse Tracker 'allocates' channels to notes whenever they
  348. are *PLAYED*. In sample mode, the allocation is simple:
  349.                         Virtual Channel = 'Host' channel
  350.  
  351. In instrument mode, the following procedure is used:
  352.  
  353.     Check if channel is already playing ---Yes--> set 'background' flag on.
  354.                 |                                 'Trigger' NNA. If NNA=cut,
  355.                 No                                then use this virtual
  356.                 |                                 channel.
  357.                 |                                          |
  358.                 |<------------------ else -----------------/
  359.                 |
  360.                 v
  361.     Search and find the first non-active virtual channel.
  362.                 |
  363.     Non-active channel found? ----Yes----> Use this for playback.
  364.                 |
  365.                 No
  366.                 |
  367.                 v
  368.    Search through and find the channel of lowest volume that is in the
  369.    'background' (ie. no longer controlled directly)
  370.                 |
  371.    Background channel found? ----Yes----> Use this for playback.
  372.                 |
  373.                 No
  374.                 |
  375.                 v
  376.    Return error - the note is *NOT* allocated a channel, and hence is not
  377.    played.
  378.  
  379.    Actually, this is quite a simple process... just that it's another of
  380.    those 'hassles' to have to write...
  381.